magiclanternfandomcom-20200223-history
Build instructions/Unified
These are build instructions for the 550D branch of Magic Lantern. Credits goto Arm.Indy and Phil. =Installing arm-elf-gcc= Step 1. '''Download the summon-arm-toolchain script (by Uwe Hermann, github repo here) and edit it as follows: TARGET=arm-elf PREFIX=${HOME}/arm-toolchain # Install location of your final toolchain PARALLEL="-j 3" # Or: PARALLEL="-j 5" for 4 cores, "-j 9" for 2 Quad Cores etc. Or just ignore it. DARWIN_OPT_PATH=/opt/local # Path in which MacPorts or Fink is installed BINUTILS=binutils-2.19.1 GCC=gcc-4.3.2 NEWLIB=newlib-1.17.0 GDB=gdb-7.1 '''Step 2. '''Get the dependencies, as described in summon-arm-toolchain's README. *For '''Debian/Ubuntu, they are: sudo apt-get install flex bison libgmp3-dev libmpfr-dev libncurses5-dev libmpc-dev autoconf texinfo build-essential *For Mac OS X, you need to install gmp, mpfr, libmpc, libiconv and wget packages using MacPorts: sudo port install gmp mpfr libmpc libiconv wget I don't use Mac, so if these instructions do not work, please edit them. Is it possible to install all the packages at once? (i.e. port install gmp mpfr mpc libiconv) *For other Linux distros, use the package management system (yum, zypper etc.) and be careful, since the packages may have a slightly different name. 'Step 3. '''Run the script (it will take a long time): bash summon-arm-toolchain This will install arm-elf-gcc under ~/arm-toolchain/bin. '''Step 4. '''Test the installation by compiling a Hello World program: hello.c #include #include int main() { int x; x = 5; } ~/arm-toolchain/bin/arm-elf-gcc -c hello.c You should get a file named ''hello.o . When compiling without "-c", it may complain about missing _exit and _sbrk, but this is OK according to this forum post. 'Step 5. '''You may also like to add the arm-elf-gcc binaries to your PATH. This is ''not required for building Magic Lantern, but might help in some cases. PATH=~/arm-toolchain/bin/:$PATH =Compiling Magic Lantern / 550D= Next, get the source code (550D branch) and the precompiled magiclantern.fir: hg clone -r 550d https://bitbucket.org/hudson/magic-lantern/ && cd magic-lantern wget http://bitbucket.org/hudson/magic-lantern/downloads/magiclantern-550d.rc1.zip unzip magiclantern-550d.rc1.zip magiclantern.fir Make these changes to the Makefile: diff -r 7309f68e78ae Makefile --- a/Makefile Sat Sep 04 10:07:59 2010 -0400 +++ b/Makefile Mon Sep 06 21:55:21 2010 +0200 @@ -1,8 +1,10 @@ -ARM_PATH=/opt/local/bin -CC=$(ARM_PATH)/arm-elf-gcc-4.3.2 -OBJCOPY=$(ARM_PATH)/arm-elf-objcopy -AR=$(ARM_PATH)/arm-elf-ar -RANLIB=$(ARM_PATH)/arm-elf-ranlib +ARM_PATH=~/arm-toolchain +ARM_BINPATH=$(ARM_PATH)/bin +GCC_VERSION=4.3.2 +CC=$(ARM_BINPATH)/arm-elf-gcc-$(GCC_VERSION) +OBJCOPY=$(ARM_BINPATH)/arm-elf-objcopy +AR=$(ARM_BINPATH)/arm-elf-ar +RANLIB=$(ARM_BINPATH)/arm-elf-ranlib LD=$(CC) HOST_CC=gcc HOST_CFLAGS=-g -O3 -W -Wall @@ -25,7 +27,8 @@ # Firmware file IDs FIRMWARE_ID_5D = 0x80000218 FIRMWARE_ID_7D = 0x80000250 -FIRMWARE_ID = $(FIRMWARE_ID_5D) +FIRMWARE_ID_550D = 0x80000270 +FIRMWARE_ID = $(FIRMWARE_ID_550D) # PyMite scripting paths PYMITE_PATH = $(HOME)/build/pymite-08 @@ -217,7 +220,7 @@ lib_a-strcoll.o \ lib_a-ctype_.o \ -ARM_LIBC_A = /opt/local/arm-elf/lib/libc.a +ARM_LIBC_A = $(ARM_PATH)/arm-elf/lib/libc.a $(STDIO_OBJ): $(ARM_LIBC_A) $(AR) xv $? $(STDIO_OBJ) @@ -326,7 +329,7 @@ %.dis: %.bin - $(ARM_PATH)/arm-linux-objdump \ + $(ARM_BINPATH)/arm-linux-objdump \ -b binary \ -m arm \ -D \ @@ -419,7 +422,7 @@ if=$< \ bs=1 \ conv=notrunc \ - oseek=0 \ + seek=0 \ 550d-empty.fir: 550d-empty.hdr ( cat $< ; \ @@ -489,7 +492,7 @@ # Quiet the build process build = \ - @if [ "$V" 1 ]; then \ + @if [ X"$V" = X"1" ]; then \ echo '$2'; \ else \ printf "[ %-8s ] %s\n" $1 $@; \ Run make and keep your fingers crossed! make This will compile a new autoexec.bin, which contains unencrypted ARM code, ready to brick your camera (God forbid...) See Build_instructions for next steps. TODO: there are still some problems with the fonts... (see here) =Building the documentation= Just run: doxygen and then browse to docs/html/index.html. For more fancy output, install Graphviz and put these settings into the Doxyfile: FILE_PATTERNS = *.c *.h *.S HAVE_DOT = YES CALL_GRAPH = YES CALLER_GRAPH = YES =Fixing common compiling problems= Magic Lantern is not easy to compile, and this section attempts to provide a little guidance if some problems appear. Please feel free to improve this if you succeed in compiling Magic Lantern. arm-elf-gcc not found Check the paths and version number in the Makefile. It should look like this: ARM_PATH=~/arm-toolchain/bin CC=$(ARM_PATH)/arm-elf-gcc-4.3.2 OBJCOPY=$(ARM_PATH)/arm-elf-objcopy AR=$(ARM_PATH)/arm-elf-ar RANLIB=$(ARM_PATH)/arm-elf-ranlib ... The arm-elf directory, ~/arm-toolchain/bin, is not required to be in PATH. You should be able to invoke arm-elf-gcc from the terminal with this command: $ ~/arm-tool-chain/bin/arm-elf-gcc-4.3.2 Make sure you install arm-elf-gcc with the summon-arm-toolchain script. I've tested 5 other builds of arm-elf-gcc, and none of them was able to compile Magic Lantern. libc.a problems Magic Lantern extracts some functions from the standard C library. Some arm-elf-gcc builds don't have libc.a, while others have up to 20 versions of libc.a (which one is good?!) Solution: just do a fresh install of arm-elf-gcc with summon-arm-toolchain, as described on top of this page. Some fonts does not show when running the compiled ML on the camera This may happen if you don't have bigtext and the Makefile font-*.in rules are executed when they should not. I believe this can happen if your date/time is set incorrectly. In this case, some font-*.c files become empty. This should be fixed, either in the Makefile or in the script which creates them. Until this problem is fixed, see Arm.Indy's workaround here. make: No rule to make target `lua-glue.o'. This appears if you try to build the 5D branch with these instructions. You have to turn it off in the Makefile: CONFIG_LUA = n and re-build with: make clean make Sometimes, running make clean fixes strange compiling problems... and sometimes not. =Operating system specific notes= Ubuntu You can use this virtual machine: http://www.vmware.com/appliances/directory/542303 Also tested on Ubuntu Karmic. Mac todo... Do not use TextEdit or MS Word to edit script files! Use a plain ASCII editor, like TextWrangler or vi. =Compilers which do not work= I have tried the following compilers on Ubuntu Karmic. None of them worked, maybe 'cause they detected that I'm not a Linux guru :) * Prebuilt arm-elf-gcc 3.4.6 from http://www.idt.mdh.se/kurser/cdt214/#athome. It seems to work, but you have to modify the Makefile in several places. Resulting autoexec.bin is huge (over 700k), while the good one is around 150k. OpenHardware says it has some bugs which can lead to stack corruption. * Build 4.3.2 / 4.3.3 from source: see http://chdk.wikia.com/wiki/Gcc433 . For 4.3.2 just do a find/replace. Complains about missing headers and doesn't include libc.a. I don't know how to build it. * Zylin 4.3.2 (arm-elf-gcc). Complains about missing headers. Has 20 versions of libc.a (!) * CodeSourcery 4.3.2 (arm-none-linux-gnueabi-gcc). Finds headers, but complains about undefined reference to `raise'. Has 3 versions of libc.a. * Prebuilt 4.3.1: get chdk_linux_compiler (Python GUI) and run it. It will install arm-elf-gcc under newenv subdirectory. It compiles CHDK successfully, but not ML. It complains about missing headers even for hello world programs (don't know why). Doesn't include libc.a.